﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XYZCompiler
{
    class CompilePartResult
    {
        public CompilePartResult(FlowController.CompileState s,object r)
        {
            State = s;
            CurrentStageResult = r;
        }
        public FlowController.CompileState State { get; private set; }
        public object CurrentStageResult { get; private set; }
    }
    /// <summary>
    /// Compile part DOES NOT HAVE state
    /// it accept preview state result and return this part result
    /// </summary>
    abstract class CompilePartBase
    {
        /// <summary>
        /// when compile error occurred
        /// </summary>
        /// <param name="s">Origin string</param>
        /// <param name="column">colunm number</param>
        /// <param name="row">row number</param>
        public delegate void PartErrorHandler(string s, int column, int row);

        public event PartErrorHandler PartError;

        protected void  NotifyError(string s, int c, int r)
        {
            if (PartError != null)
                PartError(s, c, r);
        }

        protected bool _hasError = false;
        abstract public string CompilePartName { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        abstract public CompilePartResult Excute(object param);
        

    }
}
